function [ExpIDinfo]=read_info_from_ExpLog(ExpID,varargin)

rdata_dir = [];
ExpIDinfo = struct;

if ~isempty(varargin)
    numIndex = find(cellfun('isclass', varargin(1:end-1), 'char'));
    for ind = 1:length(numIndex)
        switch lower(varargin{numIndex(ind)})
            case 'rdata_dir'
                rdata_dir = varargin{numIndex(ind) + 1};
        end
    end
end

cn_str = 'PROVIDER=SQLOLEDB; Data Source=PIA1; initial catalog=ExpLog; User ID=explog_user; password=Keller123';
DB = adodb_connect(cn_str, 240);
sql = 'SELECT Stacks.stackid, Stacks.expid, Stacks.comment, Experiments.siteid, Experiments.analysiscode, Sites.animalid, Sites.project, Animals.pi FROM Stacks INNER JOIN Experiments ON Stacks.expid=Experiments.expid INNER JOIN Sites ON Experiments.siteid=Sites.siteid INNER JOIN Animals ON Sites.AnimalID=Animals.AnimalID';
ExpLog = adodb_query(DB, sql);
DB.release;

stacks_ind=find(cell2mat(ExpLog.expid)==ExpID);

if ~isempty(stacks_ind)
    ExpIDs=cell2mat(ExpLog.stackid(stacks_ind));
else
    disp('No matching entry in stacks.xls found. Aborting');
    return
end

userID=unique(ExpLog.pi(stacks_ind));
ExpIDinfo.userID=userID{1};

mouse_id=unique(ExpLog.animalid(stacks_ind));
ExpIDinfo.mouse_id=mouse_id{1};

for ind=1:length(ExpIDs)
    ExpIDinfo.fnames{ind} = ['S1-T' num2str(ExpIDs(ind)) '_ch525.bin'];
end

% check for 2nd channel
if ~isempty(rdata_dir)
    if exist([rdata_dir ExpIDinfo.userID '\' ExpIDinfo.mouse_id  '\' 'S1-T' num2str(ExpIDs(1)) '_ch610.bin'],'file')
        for ind=1:length(ExpIDs)
            ExpIDinfo.fnames2{ind} = ['S1-T' num2str(ExpIDs(ind)) '_ch610.bin'];
        end
    end
end

for ind=1:length(ExpIDs)
    ExpIDinfo.aux_files{ind} = ['S1-T' num2str(ExpIDs(ind)) '.lvd'];
end